﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class MenusControllerBase : Controller{
	public MenusControllerBase()
		: base()
	{
	}
	private static MenusDAO _Service; 
	public static MenusDAO Service{
		get{
			if(_Service==null)
				_Service = new MenusDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public MenusEntity MapDataRowToObject(DataRow row){
		MenusEntity o = new MenusEntity();
		 o.MenuName=Convert.ToString(row["MenuName"]);
		 o.Description=Convert.ToString(row["Description"]);
		 o.IconName=Convert.ToString(row["IconName"]);
		 o.MenuUrl=Convert.ToString(row["MenuUrl"]);
		 if(!row.IsNull("DisplayIndex"))
			o.DisplayIndex=ConvertInt(row["DisplayIndex"]);
		 if(!row.IsNull("ParentId"))
			o.ParentId=(Int32)(row["ParentId"]);
		 if(!row.IsNull("ModuleId"))
			o.ModuleId=(Int32)(row["ModuleId"]);
		 if(!row.IsNull("MenuId"))
		    o.MenuId=(Int32)(row["MenuId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(MenusEntity o,DataRow row){
		row["MenuName"]=o.MenuName;
		row["Description"]=o.Description;
		row["IconName"]=o.IconName;
		row["MenuUrl"]=o.MenuUrl;
		row["DisplayIndex"]=o.DisplayIndex;
		row["ParentId"]=o.ParentId;
		row["ModuleId"]=o.ModuleId;
		row["MenuId"]=o.MenuId;
    }
}
}
